home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / snip9_91.arc / ANSISYS.C < prev    next >
C/C++ Source or Header  |  1991-09-17  |  2KB  |  61 lines

  1. /*****************************************************************************
  2.  * 
  3.  * program that detects the presence (or absence) of an ANSI device driver.
  4.  *
  5.  * Returns:
  6.  *
  7.  * errorlevel 0: Ansi devicedriver not detected.
  8.  * errorlevel 1: Ansi devicedriver detected.
  9.  *
  10.  *****************************************************************************
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <conio.h>
  16.  
  17.  
  18.  
  19. /********************************** print () *********************************
  20.  *
  21.  * A dum print string routine
  22.  *
  23.  *****************************************************************************
  24.  */
  25.  
  26. void print(char *p)
  27. {
  28.       while(*p)
  29.             putchar(*p++);
  30.       fflush(stdout);                 /* necessary for ZTC                  */
  31.  
  32. }     /* print () */
  33.  
  34. /********************************** main () **********************************
  35.  *
  36.  * Detect whether ANSI.SYS is present and return 1 if so, else returns 0
  37.  *
  38.  *****************************************************************************
  39.  */
  40.  
  41. int main(void)
  42. {
  43.       char buffer [31];               /* temporary buffer                   */
  44.       int  nr=0;                      /* counter                            */
  45.  
  46.       print("\x1b[6n\r      \r");     /* ask for ansi device report         */
  47.  
  48.       while ((0 !=kbhit()) && (nr<30))/* read whatever input is present     */
  49.             buffer[nr++] = (char)getch();
  50.  
  51.       buffer[nr]='\0';                /* zero terminate string              */
  52.  
  53.       if (strstr(buffer, "\x1b["))    /* check precense of device report    */
  54.             return 1;                 /* signal ANSI.SYS present            */
  55.       else  return 0;                 /* signal ANSI.SYS not present        */
  56.  
  57.  
  58. }  /* main ()  */
  59.  
  60. /********************************** end *************************************/
  61.